<?php

if (!defined('DIR_SEP'))
    define('DIR_SEP', DIRECTORY_SEPARATOR);

if (!defined('MODULES_DIR'))
    define('MODULES_DIR', dirname(__FILE__).DIR_SEP."..".DIR_SEP);

require_once(MODULES_DIR."IManager.inc");
require_once(MODULES_DIR."log.inc");
require_once(MODULES_DIR."config.inc");
require_once(MODULES_DIR."util.inc");

class PagesManager implements IManager
{
	public function getAdminMenu()
	{
		global $G_HOME;
		return "<li class='navCategory'>Pages management</li>
			<li class='navItem'><a href='".Util::combinePath($G_HOME,"index.php?pg=manage_pages")."'>Manage pages</a></li>";
	}
	
	public function getMenu()
	{
		global $G_HOME;

		$menuTitle = Config::getInstance()->get('/site/features/pages/menu/user/@title');
		
		if(isset($menuTitle) && strlen($menuTitle) > 0)
			$menu =  "<li class='navCategory'>".$menuTitle."</li>";
		
		$files = PagesLoader::listPages();
				
		foreach($files as $li)
		{
			if($li['showInMenu'] == 'on')
				$menu .= "<li class='navItem'><a href='".Util::combinePath($G_HOME,$li['filename'].".html")."'>".$li['name']."</a></li>";
		}

		return $menu;
	}
}

?>